import store from '@/store';
import {
    getJobListInfoService,
    getDistrictListService,
    getSettlementListService,
    getCityListService,
} from '../service';

/**
 * 获取城市列表
 */
export async function getCityList(payload = {}) {
    const allData = await getCityListService(payload);
    if (allData.code >= 2000 && allData.code < 4000) {
        store.commit('setCityList', allData.data); // 将获取到的数据值存到store中
    }
    return allData;
}

/**
 * 获取区县列表
 */
export async function getDistrictList(payload = {}) {
    const allData = await getDistrictListService(payload);
    if (allData.code >= 2000 && allData.code < 4000) {
        store.commit('setDistrictList', allData.data); // 将获取到的数据值存到store中
    }
    return allData;
}

/**
 * 获取结算方式列表
 */
export async function getSettlementList(payload = {}) {
    const allData = await getSettlementListService(payload);
    if (allData.code >= 2000 && allData.code < 4000) {
        store.commit('setSettlementList', allData.data); // 将获取到的数据值存到store中
    }
    return allData;
}

/**
 * 获取招聘职位列表信息
 */
export async function getJobListInfo(payload = {}) {
    const allData = await getJobListInfoService(payload);
    if (allData.code >= 2000 && allData.code < 4000) {
        if (payload.pageParam.page == 1) {
            store.commit('clearJobListInfo', allData.data); // 清空列表页
        }
        store.commit('setJobListInfo', allData.data); // 将获取到的数据值存到store中
    }
    return allData;
}
